<?php
/**
 * Note: 模型服务提供者
 * Date: 2021/5/14
 */
namespace App\Providers;

use App\Models\Game\Center\AppAppid;
use App\Models\Game\Center\AppResource;
use App\Models\Game\Center\AppSource;
use App\Models\Game\Center\AppSourceConfig;
use App\Models\Game\Center\AppVersion;
use App\Models\Game\Center\AppWebpage;
use App\Models\Game\Center\UuidWhiteList;
use App\Models\Manager;
use App\Models\Role;
use App\Models\SmsSign;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\ServiceProvider;

class ModelServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // 模型事件观察者
        Manager::observe(\App\Observers\ManagerObserver::class);
        Role::observe(\App\Observers\RoleObserver::class);
        SmsSign::observe(\App\Observers\SmsSignObserver::class);

        // 游戏库变动通知服务端
        AppAppid::observe([
            \App\Observers\Game\Center\AppAppidObserver::class,
            \App\Observers\GameServerTableObserver::class,
        ]);
        AppWebpage::observe([
            \App\Observers\Game\Center\AppWebpageObserver::class,
            \App\Observers\GameServerTableObserver::class,
        ]);
        AppSource::observe([
            \App\Observers\Game\Center\AppSourceObserver::class,
            \App\Observers\GameServerTableObserver::class,
        ]);
        AppSourceConfig::observe([
            \App\Observers\Game\Center\AppSourceConfigObserver::class,
            \App\Observers\GameServerTableObserver::class,
        ]);
        AppResource::observe([
            \App\Observers\Game\Center\AppResourceObserver::class,
            \App\Observers\GameServerTableObserver::class,
        ]);
        AppVersion::observe([
            \App\Observers\Game\Center\AppVersionObserver::class,
            \App\Observers\GameServerTableObserver::class,
        ]);
        UuidWhiteList::observe([
            \App\Observers\Game\Center\UuidWhiteListObserver::class,
            \App\Observers\GameServerTableObserver::class,
        ]);
        // 自定义多态类名称
        Relation::morphMap([
            // 'task_type_02' => TaskType02::class,
            // 'task_type_03' => TaskType03::class,
        ]);
    }

    public function register()
    {
        //
    }
}
